-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update to pydantic v2 #16
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Use new way of configuring models and new type of validators.
Disable pylint errors due to incompatibility with pydantic. Consider using a different linter.
Add a ruff check to CI - Tests as well.
This version supports both pydantic v1 and v2.
This is achieved through `from __future__ import annotations`, which can be removed once the minimum supported Python version has been upped to 3.10.
Ruff is already run through the pre-commit CI run
Remove commented out pylint config section
Use typing.Annotated and model_dump()
As of v0.4.0, OTELib support pydantic v2.
@quaat and @Treesarj, I think I'll merge this. It shouldn't change any contents, really, just update usage of pydantic to pydantic v2 styling - and then there's a bit of static typing updates as well. Since both |
quaat
approved these changes
Oct 27, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Use new way of configuring models and new type of validators.
Closes #12
I put this as a draft for now, to determine whether other parts of the code should be re-written according to new pydantic v2 functionality. Like, e.g., the dynamic model creation using
create_model()
.Furthermore, since dependencies of this package pin pydantic to v1 still, it is difficult to see an update happening right now.
This PR now does a few things, along with migrating to pydantic v2(EDIT: Nope, it just migrates):EDIT: This has been done.
from __future__ import annotations
, which should be removed once the minimum required Python version is set to 3.10).EDIT: This has been reverted - it doesn't work. Since Python 3.9 is the minimum supported version, Python 3.9 style typing has been implemented everywhere. Note, this can also be done dynamically using the
pyupgrade
package with the--py39-plus
option (for example as a pre-commit hook, if so desired).